const gulp = require('gulp');
const less = require('gulp-less');
const autoprefixer = require('autoprefixer');
const cssnano = require('cssnano');
const postcss = require('gulp-postcss');
const plumber = require('gulp-plumber');

const b_src = 'src';
const b_dist = 'static';

// 编译样式
gulp.task('css', function () {
  return gulp.src(b_src + '/less/*.less')
    .pipe(plumber({
      errorHandler(err) {
        console.log(err);
        this.emit('end');
      }
    }))
    .pipe(less())
    .pipe(postcss([autoprefixer(), cssnano({
      zindex: false
    })]))
    .pipe(gulp.dest(b_dist + '/css'));
});



gulp.task('dev', ['css'], function () {
  console.log('[工作中..] 👷 👷');
  gulp.watch(b_src + '/less/**/*.less', ['css']);
});